﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace WQDSkin.Forms.Controls
{
    public  class WQDTabItem :TabItem
    {
        public override void OnApplyTemplate()
        { 
            base.OnApplyTemplate();

            Grid close = (Grid)this.GetTemplateChild("close"); 
            if(close != null)
            {  
                close.MouseLeftButtonDown += Close_MouseLeftButtonDown;
            }
        }

        private void Close_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            TabControl tabControl = (TabControl)this.Parent;
            tabControl.Items.Remove(this);
        }

        public CornerRadius CornerRadius
        {
            get { return (CornerRadius)GetValue(CornerRadiusProperty); }
            set { SetValue(CornerRadiusProperty, value); }
        }
        public static readonly DependencyProperty CornerRadiusProperty =
            DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(WQDTabItem), new PropertyMetadata(null));
 
        public SolidColorBrush ThemeColor
        {
            get { return (SolidColorBrush)GetValue(ThemeColorProperty); }
            set { SetValue(ThemeColorProperty, value); }
        }
         
        public static readonly DependencyProperty ThemeColorProperty =
            DependencyProperty.Register("ThemeColor", typeof(SolidColorBrush), typeof(WQDTabItem),
                new PropertyMetadata(WQDSystemColors.ThemeBackground));

        /// <summary>
        /// 选中背景色
        /// </summary>
        public SolidColorBrush SelectedBackground
        {
            get { return (SolidColorBrush)GetValue(SelectedBackgroundProperty); }
            set { SetValue(SelectedBackgroundProperty, value); }
        }
 
        public static readonly DependencyProperty SelectedBackgroundProperty =
            DependencyProperty.Register("SelectedBackground", typeof(SolidColorBrush), typeof(WQDTabItem), 
                new PropertyMetadata(new SolidColorBrush(Colors.White)));
         
        [Description("图标"), Category("WQDSkin")]
        public Geometry Icon
        {
            get { return (Geometry)GetValue(IconProperty); }
            set { SetValue(IconProperty, value); }
        }
        public static readonly DependencyProperty IconProperty =
            DependencyProperty.Register("Icon", typeof(Geometry), typeof(WQDTabItem), new PropertyMetadata(null));

        /// <summary>
        /// 图下旋转角度
        /// </summary>
        public int Angle
        {
            get { return (int)GetValue(AngleProperty); }
            set { SetValue(AngleProperty, value); }
        }
         
        public static readonly DependencyProperty AngleProperty =
            DependencyProperty.Register("Angle", typeof(int), typeof(WQDTabItem), new PropertyMetadata(0));

         
        public double IconWidth
        {
            get { return (double)GetValue(IconWidthProperty); }
            set { SetValue(IconWidthProperty, value); }
        }
         
        public static readonly DependencyProperty IconWidthProperty =
            DependencyProperty.Register("IconWidth", typeof(double), typeof(WQDTabItem), new PropertyMetadata((double)14));

         
        public double IconHeight
        {
            get { return (double)GetValue(IconHeightProperty); }
            set { SetValue(IconHeightProperty, value); }
        }
         
        public static readonly DependencyProperty IconHeightProperty =
            DependencyProperty.Register("IconHeight", typeof(double), typeof(WQDTabItem), new PropertyMetadata((double)14));


    }
}
